<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" />
	<title>娱管家</title>  
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="x5-orientation" content="portrait">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Access-Control-Allow-Origin" content="">
	<meta http-equiv="content-security-policy">
	<script type="text/javascript" src="js/jquery.min.js" ></script>
	<!--mui样式-->
	<link rel="stylesheet" type="text/css" href="css/mui.min.css"/>
	<link rel="stylesheet" type="text/css" href="css/mui/app.css"/>
	<link rel="stylesheet" type="text/css" href="css/mui/mui.picker.css"/>
	<link rel="stylesheet" type="text/css" href="css/mui/mui.picker.min.css"/>
	<link rel="stylesheet" type="text/css" href="css/mui/mui.poppicker.css"/>
	<!--环信-->
	<script type="text/javascript" src="js/hx/strophe.js" ></script>
	<script type="text/javascript" src="js/hx/websdk-1.1.2.js"></script>
	<script type="text/javascript" src="js/hx/websdk.config.js"></script>
	<script type="text/javascript" src="js/hx/websdk.shim.js"></script> 
	<script type="text/javascript" src="js/bq.js"></script> 
	<!--环信-->
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=yWnFso0oyjmX79HzCx1DRz2sBtvweQfI"></script>
	<link rel="stylesheet" href="css/loding/fakeLoader.css"/>
	<!--头像上传-->
	<link rel="stylesheet" href="css/cropper.css"/>
	<script src="js/cropper.js"></script>
	<!-- 公共样式与字体  -->
	<link rel="stylesheet" href="css/public.css"/>
	<link rel="stylesheet" type="text/css" href="icon-font/iconfont.css"/>
	<!-- 定制样式   -->
	<link rel="stylesheet" href="css/style.css"/>
	<link rel="stylesheet" href="css/bq.css" />
	<link rel="stylesheet" type="text/css" href="css/NewStyle.css"/>
	<!-- Swiper 样式  -->
	<link rel="stylesheet" type="text/css" href="css/swiper.min.css"/>
	<link rel="stylesheet" href="css/appstyle.css" />
	<!-- 微信分享 -->
	<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
	<style type="text/css">
		.rgba{display: none;}
		html{background-color: #fff;}
	</style>
</head>
<body>
	<div class="App">
		<span>娱管家</span>
		<button>下载APP</button>
	</div>
	<div class="mui-navbar-inner mui-bar mui-bar-nav pHead header_1 " id="DealerStore2Head">
		<h2>经销商店铺</h2>
	</div>
	<main class="mui-page-content pBody DealerStore2">
		<!-- 轮播图 Start ↓↓↓↓↓↓↓ -->
		<div id="DealerStore" class="mui-slider" >
			<div class="mui-slider-group" style="transform: translate3d(0px, 0px, 0px) translateZ(0px);">
				<div class="mui-slider-item">
					<img src="images/1.jpg">
				</div>
			</div>
			<div class="mui-slider-indicator">
				<!--<div class="mui-indicator mui-active"></div>
				<div class="mui-indicator"></div>-->
			</div>
		</div>
		<!-- 轮播图 End ↑↑↑↑↑ -->
		<div class="ProductName">
			<p>产品名称<span class="iconfont icon-zan">点赞 0</span></p>
		</div>
		<div class="Product">
			<pre>eryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy</pre>
		</div>
	</main>
	<div class="rgba"></div>
	<div class="" id="tan2"></div>
	<script src="js/base.js"></script>
	<script src="js/swiper.min.js"></script>
	<script type="text/javascript">
		var share_link = location.href;
		var share_data = {
	        title: '娱管家',// 设置分享标题
	        desc: '',// 设置分享描述
	        link: share_link,// 设置分享链接
	        img: 'http://www.yuzhuli.com/Public/upload/image/170429_015749_8761.jpg'// 分享图片
	    };
		function tan(text2){
			$("#tan2").addClass("tan");
			$("#tan2").text(text2);
			clearTimeout(a);
			var a = setTimeout (function(){
				ding();
			},2000);
			function ding (){
				$("#tan2").removeClass("tan");
				$("#tan2").text("");
			};
		}
		function getCache(key){
			if(localStorage.getItem(key)){
				return JSON.parse(localStorage.getItem(key));
			}else{
				return false;
			}
		}
		var token = GetQueryString('token');
		$('.App button').unbind('click').on('click',function(){
			location.href = 'http://www.yuzhuli.com/Share/erweima.html?id='+token;
		});
		function initLBT(boxId,dataList){
			$('#'+boxId).empty();
			$('#'+boxId).html('<div class="swiper-container swiper_'+boxId+'"><div class="swiper-wrapper SwiperImg_'+boxId+'" style="font-size: 0;"></div><div class="swiper-pagination SwiperSpot_'+boxId+'"></div></div>');
			var html = '';
			$.each(dataList,function(i,d){
				html += '<div class="swiper-slide"><img src="' + d + '"></div>';
			});
			$('.SwiperImg_'+boxId).html(html);
			LBT('.swiper_'+boxId,'.SwiperSpot_'+boxId);
		}
	    function LBT(swiper1,swiper2) {
			//轮播图
			var swiper = new Swiper(swiper1, {
				pagination: swiper2,
				paginationClickable: true,
				loop:true
			});
			swiper.update();
		}
	    
	    function GetQueryString(name){
		    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		    var r = window.location.search.substr(1).match(reg);
		    if(r!=null)return  unescape(r[2]); return null;
		}
	    
		var parm = GetQueryString('id');
		var url = 'http://www.yuzhuli.com/api.php/Api/brand_detail';
		
		$('.Product pre').empty();
		$('#DealerStore .mui-slider-group').empty();
		$.post(url,{id:parm},function(obj){
			if(obj.s){
				$('.ProductName p').html(obj.d.product_name + '<span class="iconfont icon-zan">点赞'+obj.d.thumbs_up+'</span>');
				$('.Product pre').html(obj.d.content);
				$('#DealerStore2Head h2').text(obj.d.brand_name);
				var html = '';
				var html2 = '';
				$.each(obj.d.imgs,function(i,d){
					html += '<div class="mui-slider-item"><img src="'+d+'"></div>';
				});
				var num = obj.d.imgs.length;
				for(var e = 1;e <= num;e++){
					html2 += '<div class="mui-indicator"></div>';
				};
				$('.mui-slider-group').html(html);
				$('.mui-slider-indicator').html(html2);
				$('.mui-slider-indicator .mui-indicator').eq(0).addClass('mui-active');
				var ss = '<script src="js/muijs/mui.min.js"><\/script><script src="js/muijs/mui.picker.min.js"><\/script><script src="js/muijs/mui.poppicker.js"><\/script>';
				$('body').append(ss);
				czan();
				share_data.title = obj.d.product_name;
				share_data.desc = obj.d.brand_desc;
			    share_data.img = obj.d.logo;
			    getWxConfig(ApiList, wxConfigCallback, false);
			}else{
				tan(obj.m);
			}
		});
		function czan(){
			$('.ProductName .icon-zan').unbind('tap').on('tap',function(){
				tan('请下载APP 在APP里进行点赞');
//					var uurl = 'http://www.yuzhuli.com/api.php/Api/thumbs_up';
//					$.post(uurl,{id:parm},function(obj){
//						if(obj.s){
//							$('.ProductName .icon-zan').text("点赞" + obj.d.thumbs_up);
//							tan(obj.m);
//						}else{
//							if(obj.m == 'Token does not exist,Please login'){
//								mui.toast('请先登录');
//							}else{
//								mui.toast(obj.m);								
//							}
//						}
//					})
			});
		}
		  // 分享
	    function getWxConfig(ApiList, callback, debug) {    		
	        $.ajax({
	            url: 'http://www.yuzhuli.com/api.php/api/wechat_js_config',
	            type: 'POST',
	            dataType: 'json',
	            data: {url: location.href,apis:ApiList,debug:debug},
	        }).done(function (res) {
	        	console.log(res);
	            if (res.s) {
	                var con = res.config;
	                var wxConf = {
	                    debug: debug,
	                    appId: con.appId,
	                    timestamp: con.timestamp,
	                    nonceStr: con.nonceStr,
	                    signature: con.signature,
	                    jsApiList: ApiList
	                };
	                wx.config(wxConf);
	                wx.ready(function () {
	                    callback();
	                });
	            }
	        }).fail(function () {
	            console.log("error");
	        }).always(function () {
	            console.log("complete");
	        });
	    }
	    var ApiList = [
	        'onMenuShareTimeline',
	        'onMenuShareAppMessage',
	        'onMenuShareQQ',
	        'onMenuShareQZone',
	        'onMenuShareWeibo',
	    ];	
	    
	    function wx_share(data, callback) {
	        // 分享到朋友圈
	        wx.onMenuShareTimeline({
	            title: data.title, // 分享标题
	            link: data.link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
	            imgUrl: data.img, // 分享图标
	            success: function () {
	                // 用户确认分享后执行的回调函数
	            },
	            cancel: function () {
	                // 用户取消分享后执行的回调函数
	            }
	        });
	        // 分享给朋友
	        wx.onMenuShareAppMessage({
	            title: data.title, // 分享标题
	            desc: data.desc, // 分享描述
	            link: data.link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
	            imgUrl: data.img, // 分享图标
	            type: '', // 分享类型,music、video或link，不填默认为link
	            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
	            success: function () {
	                // 用户确认分享后执行的回调函数
	            },
	            cancel: function () {
	                // 用户取消分享后执行的回调函数
	            }
	        });
	        wx.onMenuShareQQ({
				title: data.title, // 分享标题
				desc: data.desc, // 分享描述
				link: data.link, // 分享链接
				imgUrl: data.img, // 分享图标
				success: function () {
				// 用户确认分享后执行的回调函数
				},
				cancel: function () {
				// 用户取消分享后执行的回调函数
				}
			});
			wx.onMenuShareQZone({
				title: data.title, // 分享标题
				desc: data.desc, // 分享描述
				link: data.link, // 分享链接
				imgUrl: data.img, // 分享图标
				success: function () {
				// 用户确认分享后执行的回调函数
				},
				cancel: function () {
				// 用户取消分享后执行的回调函数
				}
			});
			wx.onMenuShareWeibo({
				title: data.title, // 分享标题
				desc: data.desc, // 分享描述
				link: data.link, // 分享链接
				imgUrl: data.img, // 分享图标
				success: function () {
				// 用户确认分享后执行的回调函数
				},
				cancel: function () {
				// 用户取消分享后执行的回调函数
				}
			});
	    }	
	    var shareCallback = function (type, status) {
			
	    }	
	    var wxConfigCallback = function () {
//	    	$("audio")[0].play();
	        wx_share(share_data, shareCallback);	        
	    }	
	    
	    wx.error(function (res) {
	        console.log(JSON.stringify(res));
	        // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
	    }); 
	</script>
	
</body>
</html>
